#include "MenuView.h"

MenuView::MenuView()
{
    init();
}

void MenuView::init() {
    createMenu();
    createActions();
}

void MenuView::createMenu() {
    menuProgram = new QMenu("Program");
    menuMultiplayer = new QMenu("Gra wieloosobowa");
    menuHelp = new QMenu("Pomoc");

    addMenu(menuProgram);
    addMenu(menuMultiplayer);
    addMenu(menuHelp);
}

void MenuView::createActions() {
    //Menu Gra
    actionConsole = new QAction(tr("Konsola"), this);
    actionChooseFile = new QAction(tr("Wczytaj rozgrywkę..."), this);
    actionOptions = new QAction(tr("Opcje"), this);
    actionQuit = new QAction(tr("Wyjście"), this);   

    actionConsole->setShortcut(QKeySequence(tr("Ctrl+C")));
    actionChooseFile->setShortcut(QKeySequence(tr("Ctrl+L")));
    actionOptions->setShortcut(QKeySequence(tr("Ctrl+O")));

    menuProgram->addAction(actionChooseFile);
    menuProgram->addAction(actionConsole);
    menuProgram->addSeparator();
    menuProgram->addAction(actionOptions);
    menuProgram->addSeparator();
    menuProgram->addAction(actionQuit);

    connect(actionConsole, &QAction::triggered, [=](){ emit actionConsoleSignal(); });
    connect(actionOptions, &QAction::triggered, [=](){ emit actionOptionsSignal(); });
    connect(actionChooseFile, &QAction::triggered, [=](){ emit actionChooseFileSignal(); });
    connect(actionQuit, &QAction::triggered, [=](){ emit actionQuitSignal(); });

    //Menu Gra wieloosobowa

    //Menu Pomoc
    actionAbout = new QAction(tr("O programie"), this);

    actionAbout->setShortcut(QKeySequence(tr("Ctrl+I")));

    connect(actionAbout, &QAction::triggered, [=](){ emit actionAboutSignal(); });

    menuHelp->addAction(actionAbout);
}
